import { baseRequestClient, requestClient } from '#/api/request';

export namespace OutsourceRecpt {
  export interface Params {
    attr1: null;
  }

  export interface Row {
    searchValue: null;
    createBy: string;
    createTime: Date;
    updateBy: string;
    updateTime: Date;
    remark: string;
    params: Params;
    recptId: number;
    recptCode: string;
    recptName: string;
    iqcId: null;
    iqcCode: null;
    workorderId: number;
    workorderCode: string;
    vendorId: number;
    vendorCode: string;
    vendorName: string;
    vendorNick: null;
    warehouseId: null;
    warehouseCode: null;
    warehouseName: null;
    locationId: null;
    locationCode: null;
    locationName: null;
    areaId: null;
    areaCode: null;
    areaName: null;
    recptDate: Date;
    status: string;
    attr2: null;
    attr3: number;
    attr4: number;
    attr1: boolean | null | string;
  }

  export interface GetListParams {
    pageNum: number;
    pageSize: number;
  }
  export interface GetListReturn {
    total: number;
    rows: Row[];
    code: number;
    msg: string;
  }
}

// 获取列表
export const getOutsourceRecptTableList = (
  params: OutsourceRecpt.GetListParams,
) =>
  requestClient.get<OutsourceRecpt.GetListReturn>(
    '/mes/wm/outsourcerecpt/list',
    {
      params,
    },
  );

// 修改外协入库
export const updateOutsourceRecpt = (data: OutsourceRecpt.Row) =>
  requestClient.put<OutsourceRecpt.GetListReturn>(
    '/mes/wm/outsourcerecpt',
    data,
  );

// 增加外协入库
export const addOutsourceRecpt = (data: OutsourceRecpt.Row) =>
  requestClient.post<OutsourceRecpt.GetListReturn>(
    '/mes/wm/outsourcerecpt',
    data,
  );

// 删除外协入库
export const deleteOutsourceRecpt = (id: string) =>
  requestClient.delete<OutsourceRecpt.GetListReturn>(
    `/mes/wm/outsourcerecpt/${id}`,
  );

// 获取自动生成编码
export const getOutsourceRecptCode = () =>
  baseRequestClient.get<any>('/system/autocode/get/OUTSOURCE_ISSUE_CODE');
